package com.frogs.ucenter.v1.request;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.UserRegisterTypeEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.ucenter.util.CpsConstant;

/**
 * 开发平台绑定请求参数类
 *
 * @author lijian
 * @version 2014年6月30日 - 上午9:46:06
 */
public class OpenPlatformBindAndLoginRequest extends Request {
	
	/**
	 * 手机验证码
	 */
	private String code;
	
	private String openId;
	
	private String userName;
	
	private String nickName;
	
	private String password;
	
	private String confirmPassword;
	
	private String expandCode;
	
	/**
	 * 是否手机动态密码登录绑定
	 * 0：不是，1：是
	 */
	private Integer isphpw;
	
	private String accessToken;
	
	private String refreshToken;
	
	private Date expiresDate;
	
	private Integer openPlatformId;
	
	private String ip;
	
	private String email;
	
	private String phone;
	
	/**
	 * 是否属于注册流程
	 * 0：直接绑定旧账号，1：注册新账号（需要用户自己填写的账号密码），2：注册新账号（需要开放平台昵称作为账号和用户填写的密码）
	 */
	private Integer isRegister;

	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.code = requestInfo.getParameter(ApiUrlParamEnum.code.getParamName(), "");
		this.openId = requestInfo.getParameter(ApiUrlParamEnum.openId.getParamName(), "");
		this.userName = requestInfo.getParameter(ApiUrlParamEnum.username.getParamName(), "");
		this.password = requestInfo.getParameter(ApiUrlParamEnum.password.getParamName(), "");
		this.confirmPassword = requestInfo.getParameter(ApiUrlParamEnum.confirmPassword.getParamName(), "");
		this.isphpw = requestInfo.getIntParameter(ApiUrlParamEnum.isphpw.getParamName(), 0);
		this.accessToken = requestInfo.getParameter(ApiUrlParamEnum.accessToken.getParamName(), "");
		this.refreshToken = requestInfo.getParameter(ApiUrlParamEnum.refreshToken.getParamName(), "");
		this.expiresDate = requestInfo.getDateParameter(ApiUrlParamEnum.expiresDate.getParamName(), "yyyy-MM-dd HH:mm:ss");
		this.openPlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.openPlatformId.getParamName(), 0);
		this.ip = requestInfo.getParameter(ApiUrlParamEnum.ip.getParamName(), requestInfo.getUserIp());
		this.email = requestInfo.getParameter(ApiUrlParamEnum.email.getParamName(), "");
		this.phone = requestInfo.getParameter(ApiUrlParamEnum.phone.getParamName(), "");
		this.expandCode = requestInfo.getParameter(ApiUrlParamEnum.expandCode.getParamName(), requestInfo.getCookieValue(CpsConstant.CPS_SOURCE_NAME, ""));
		this.isRegister = requestInfo.getIntParameter(ApiUrlParamEnum.isRegister.getParamName(), UserRegisterTypeEnum.REGISTER_BIND_OLD.getId());
		this.nickName = requestInfo.getParameter(ApiUrlParamEnum.nickName.getParamName(), "");
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getOpenId() {
		return openId;
	}

	public void setOpenId(String openId) {
		this.openId = openId;
	}

	public Integer getOpenPlatformId() {
		return openPlatformId;
	}

	public void setOpenPlatformId(Integer openPlatformId) {
		this.openPlatformId = openPlatformId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public String getAccessToken() {
		return accessToken;
	}

	public void setAccessToken(String accessToken) {
		this.accessToken = accessToken;
	}

	public String getRefreshToken() {
		return refreshToken;
	}

	public void setRefreshToken(String refreshToken) {
		this.refreshToken = refreshToken;
	}

	public Date getExpiresDate() {
		return expiresDate;
	}

	public void setExpiresDate(Date expiresDate) {
		this.expiresDate = expiresDate;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public Integer getIsphpw() {
		return isphpw;
	}

	public void setIsphpw(Integer isphpw) {
		this.isphpw = isphpw;
	}

	public String getExpandCode() {
		return expandCode;
	}

	public void setExpandCode(String expandCode) {
		this.expandCode = expandCode;
	}

	public Integer getIsRegister() {
		return isRegister;
	}

	public void setIsRegister(Integer isRegister) {
		this.isRegister = isRegister;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}
}
